import request from "../server/request";

//更新轮播
export const bannerUpdate = (bannerObj) => {
  let { name, img, url, desc, objectId, isshow } = bannerObj;
  return request.put(`/classes/Banner/${objectId}`, {
    name,
    img,
    url,
    isshow,
    desc,
  });
};
//更新商品
export const productUpdate = (bannerObj) => {
  let { name, img, url, desc, objectId, isshow } = bannerObj;
  return request.put(`/classes/Banner/${objectId}`, {
    name,
    img,
    url,
    isshow,
    desc,
  });
};
//更新推荐
export const recommendUpdate = (bannerObj) => {
  let { name, img, url, desc, objectId, isshow } = bannerObj;
  return request.put(`/classes/Recommend/${objectId}`, {
    name,
    img,
    url,
    isshow,
    desc,
  });
};

//删除轮播
export const bannerDel = (objectId) => {
  return request.delete(`/classes/Banner/${objectId}`);
};
//删除商品
export const productDel = (objectId) => {
  return request.delete(`/classes/Product/${objectId}`);
};
//删除推荐
export const recommendDel = (objectId) => {
  return request.delete(`/classes/Recommend/${objectId}`);
};

//批量转存产品数据
export const productBatch = (prodList) => {
  let list = [

  ];
  prodList.forEach((item) => {
    list.push({
      method: "POST",
      path: "/1.1/classes/VueProduct",
      body: item,
    });
  });
  return request.post("/batch", { requests: list });
};
